Skip to content

Conversation

@Ecarrion
Copy link
Contributor

@Ecarrion Ecarrion commented Jan 4, 2023

closes: #8489

Why

This PR makes sure to stop the generation process and inform the merchant when there is more than 100 generations to create.

How

  • Adde a new GenerationError type with a tooManyVariations case to represent the situation where there are more than 100 variations to create.

  • Integrate the error defined above in the ViewModel and in the ViewController to properly inform the merchant via a notice.

Demo

generation-error.mov

Testing Steps


  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

@Ecarrion Ecarrion added the feature: variation list Related to the variations list for variable products. label Jan 4, 2023
@Ecarrion Ecarrion added this to the 11.8 milestone Jan 4, 2023
@Ecarrion Ecarrion requested a review from ealeksandrov January 4, 2023 03:13
@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Jan 4, 2023

You can test the changes from this Pull Request by:
  • Clicking here or scanning the QR code below to access App Center
  • Then installing the build number pr8541-5636c23 on your iPhone

If you need access to App Center, please ask a maintainer to add you.

@Ecarrion Ecarrion linked an issue Jan 4, 2023 that may be closed by this pull request
Copy link
Contributor

@ealeksandrov ealeksandrov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Loog good! Added 1 non-blocking improvement suggestion.

let variationsToGenerate = ProductVariationGenerator.generateVariations(for: product, excluding: existingVariations)
print("Variations to Generate: \(variationsToGenerate.count)")

// Guard for 100 variation limit
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we guard for this overflow early? So we won't actually create a lot of objects before failing? We should be able to quickly count possible combinations by multiplying the amount of options for each attribute.

But I'm not sure if we can easily subtract a number of existing variations - there may be duplicated combinations. Can we subtract just total number of existing variations for pre-generation guard (for a worst case)? And if it <100, we can proceed to existing check to make additional verification of combinations.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we will hit a performance problem here right now. The plan is to eventually ask core to generate variations so probably not worth spending extra time on performance unless we notice something significant!

Base automatically changed from issue/8488-product-variation-generator to trunk January 4, 2023 20:49
@peril-woocommerce
Copy link

Warnings
⚠️ This PR is assigned to a milestone which is closing in less than 2 days Please, make sure to get it merged by then or assign it to a later expiring milestone

Generated by 🚫 dangerJS

@Ecarrion Ecarrion force-pushed the issue/8489-abort-if-multiple-variations branch from bd7482e to 150782a Compare January 4, 2023 20:54
@Ecarrion Ecarrion enabled auto-merge January 4, 2023 21:16
@Ecarrion Ecarrion merged commit d5b81b1 into trunk Jan 4, 2023
@Ecarrion Ecarrion deleted the issue/8489-abort-if-multiple-variations branch January 4, 2023 22:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature: variation list Related to the variations list for variable products.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Variations: Abort if there is more than 100 local variations

4 participants